package com.senlingspace.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.senlingspace.common.annotation.RepeatSubmit;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.domain.AjaxResult;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.system.domain.SlkjRegistration;
import com.senlingspace.system.service.ISlkjRegistrationService;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.common.core.page.TableDataInfo;

/**
 * 登记机Controller
 * 
 * @author SenlingSpace
 * @date 2024-07-27
 */
@RestController
@RequestMapping("/system/registration")
public class SlkjRegistrationController extends BaseController
{
    @Autowired
    private ISlkjRegistrationService slkjRegistrationService;

    /**
     * 查询登记机列表
     */
    @PreAuthorize("@ss.hasPermi('system:registration:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlkjRegistration slkjRegistration)
    {
        List<SlkjRegistration> list = slkjRegistrationService.selectSlkjRegistrationList(slkjRegistration);
        return getDataTable(list);
    }


    /**
     * 获取登记机详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:registration:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slkjRegistrationService.selectSlkjRegistrationById(id));
    }

    /**
     * 新增登记机
     */
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PreAuthorize("@ss.hasPermi('system:registration:add')")
    @Log(title = "登记机", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlkjRegistration slkjRegistration)
    {
        return toAjax(slkjRegistrationService.insertSlkjRegistration(slkjRegistration));
    }

    /**
     * 修改登记机
     */
    @PreAuthorize("@ss.hasPermi('system:registration:edit')")
    @Log(title = "登记机", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlkjRegistration slkjRegistration)
    {
        return toAjax(slkjRegistrationService.updateSlkjRegistration(slkjRegistration));
    }

    /**
     * 删除登记机
     */
    @PreAuthorize("@ss.hasPermi('system:registration:remove')")
    @Log(title = "登记机", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slkjRegistrationService.deleteSlkjRegistrationByIds(ids));
    }
}
